import { useState, useEffect } from 'react';
import Dad from './pages/Dad/Dad';
import Context from './utils/context';
export default function App() {
  const [msg, setMsg] = useState('江肖')
  const [count, setCount] = useState('好好学习')
  const btn = () => {
    setMsg('李众')
  }
  // 初次渲染时会执行一次。当前所依赖的数据发生变化时才会执行，相当于一个侦听器
  useEffect(() => {
    console.log(999);
    setCount('天天向上')
  }, [count])

  return (
    <>
      <h1>App---{msg}---{count}</h1>
      <button onClick={btn}>点击</button>
      <Context.Provider value={msg}>
        <Dad />
      </Context.Provider>
    </>
  )
}